﻿@using WineStore.Extends;
@using PagedList.Mvc;
@using PagedList;
@model PagedList.IPagedList<WineStore.Models.CategoryNews>
@{
    ViewBag.Title = "ShowCategoryNews";
    Layout = "~/Views/Shared/AdminLayout.cshtml";
}
@section Styles
{
    <!--Sử dụng cho paging-->
    <link href="../../Content/PagedList.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        td {
            text-align: center;
            vertical-align: middle;
        }
    </style>
}
<link href="../../Content/styletablesim.css" rel="stylesheet" />
<script src="../../Scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
    $(function () {
        /* For zebra striping */
        $("table tr:nth-child(odd)").addClass("odd-row");
        /* For cell text alignment */
        $("table td:first-child, table th:first-child").addClass("first");
        /* For removing the last border */
        $("table td:last-child, table th:last-child").addClass("last");
    });
</script>
@section Scripts
{
    <!--Sử dụng cho row hover-->
    <script type="text/javascript">
        $(document).ready(function () {
            $("tr").not(':first').hover(function () {
                $(this).css("background", "#F0FFFF");
            }, function () {
                $(this).css("background", "");
            }
            );
        });
    </script>
}
<!-- Table (TABLE) -->
@if (Session["Admin"] != null)
{
    <h3 class="tit">Danh Mục Tin Tức
    </h3>
    <div style="color: Red; font-size: 13px;" id="update-message">
    </div>
    using (Html.BeginForm())
    {
    <table border="1px;" style="width:100%">
        <tr>
            <th>Ảnh đại diện
            </th>
            <th>Tên danh mục
            </th>
            <th>Sự kiện
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.ImageFor(catenews => "../../Content/Images/CategoryNews/" + item.CategoryNewsImage, new { width = "120px", height = "100px", alt = "some alt text" })
                </td>
                <td>
                    @Html.DisplayFor(catenews => item.CategoryNewsName_VN)
                </td>
                <td>
                    @Html.ActionLink("Sửa", "EditCategoryNews", new { id = item.CategoryNewsId }, new { @class="edit"})
                    @Html.ActionLink("Xóa", "DeleteCategoryNews", new { id = item.CategoryNewsId }, new { @class="edit"})
                </td>
            </tr>
        
        }
        <tr>
            <td colspan="8" align="right" style="text-align: right; vertical-align: bottom;">
                @Html.ActionLink("Thêm mới", "CreateCategoryNews", null, new { @class="edit"})
            </td>
        </tr>
    </table>
    <!--Paging-->
    @Html.PagedListPager(Model, page => Url.Action("ShowCategoryNews", new { page = page }), (PagedListRenderOptions)ViewBag.Pro)
    }
}
else
{
    Response.Redirect("~/Admin/LogOn/");
}